/*
 * Copyright (c) 2023 Cshoo Org. All Rights Reserved.
 */

package org.cshoo.tattoo.authorize.domain.repository;

import org.cshoo.tattoo.authorize.domain.po.Group;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author 杨翼
 * @since 1.0
 */
public interface IGroupRepository extends CrudRepository<Group, Long> {

    /**
     * 修改群组信息
     *
     * @param group 群组
     */
    @Query("update Group gp set gp.name = :#{#group.name}, gp.description = :#{#group.description}, gp.lastUpdatedBy = :#{#group.lastUpdatedBy}, gp.lastUpdateTime = :#{#group.lastUpdateTime} where gp.id = :#{#group.id}")
    @Transactional(rollbackFor = Exception.class)
    @Modifying
    void updateGroup(@Param("group") Group group);

}
